package leetcode.code1680;

import java.util.Iterator;

import leetcode.IDebug;
import leetcode.helper.H;

public class Solution implements IDebug {

	int mod = (int) 1e9 + 7;

	public int concatenatedBinary(int n) {
		long ans = 0;
		for (int i = 1; i <= n; i++) {
			int move = Integer.toBinaryString(i).length();
			ans <<= move;
			ans |= i;
			ans %= mod;
		}
		return (int) ans;
	}

	public int concatenatedBinary1(int n) {
		long ans = 0;
		for (int i = 1; i <= n; i++) {
			int cur = i;
			while (cur > 0) {
				cur >>= 1;
				ans <<= 1;
			}
			ans |= i;
			ans %= mod;
		}
		return (int) ans;
	}

	@Override
	public void debug4() {
		H.compare(1, this.concatenatedBinary(1));

	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug1() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		Solution so = new Solution();
		so.debug1();
		so.debug2();
		so.debug3();
		so.debug4();
		System.out.println(Math.ceil(Math.log(100) / Math.log(2)));
		System.out.println(Math.log10(5) / Math.log10(2));
		System.out.println(Integer.toBinaryString(100));
	}

}
